//
//  GMGradientImageView.m
//  mastergolf
//
//  Created by GL on 15/9/22.
//  Copyright (c) 2015年 Master. All rights reserved.
//

#import "GMGradientImageView.h"
#import "UIImageView+WebCache.h"

@implementation GMGradientImageView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

-(void)sd_setImageWithURL:(NSURL *)imgUrl placeholderImage:(UIImage *)img
{
    [self sd_setImageWithURL:imgUrl placeholderImage:img completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
        // 回调图片
//        if (cacheType == SDImageCacheTypeNone) {
//        }
        [self gradientAnimation];
    }];
}

-(void)sd_setImageWithURL:(NSURL *)imgUrl
{
    [self sd_setImageWithURL:imgUrl completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
//        if (cacheType == SDImageCacheTypeNone) {
//        }
        [self gradientAnimation];
    }];
}

-(void)gradientAnimation
{
    self.alpha = 0.1;
    [UIView animateWithDuration:0.5 animations:^{
        self.alpha = 1.0;
    }];
}

@end
